package utils;

import spring.proxy.ProxyFactory;
import spring.proxy.ProxyFactoryCreator;
import spring.proxy.ProxyType;

public final class ProxyUtils {

    private ProxyUtils() {
    }

    public static Object createProxyObject(Object originObject) {
        // 获取代理工厂对象
        ProxyType proxyType = ProxyType.CGLIB;
        if (ReflectUtils.isImplementInterface(originObject.getClass())) {
            proxyType = ProxyType.JDK;
        }
        ProxyFactory proxyFactory = ProxyFactoryCreator.getInstance().createFactory(proxyType);
        // 创建当前 bean 的实例代理对象
        return proxyFactory.create(originObject);
    }
}
